import time
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
from hyrobot.common import CHECK_POINT, STEP

from lib.webui import  *

class c73562:
    name = '验证修改密码时的输入中文字符功能-73562' # 测试用例名字

# 初始化方法
    def setup(self):
        STEP(1, '登陆网站')
        wd = open_browser()
        mgr_login(wd)

    #清除方法
    def teardown(self):
        wd = get_global_webdriver()
        wd.quit()

    # 测试用例步骤
    def teststeps(self):
        # 获取webdriver对象 对应 已经登录好的浏览器
        driver = get_global_webdriver()
        # driver = webdriver.Firefox()

        time.sleep(2)
        STEP(2, "修改密码使用中文")
        driver.find_element(By.CSS_SELECTOR,
                            ".avatar-wrapper > span:nth-child(1)"
                            ).click()
        time.sleep(2)
        driver.find_element(By.CSS_SELECTOR,
                            "li.el-dropdown-menu__item:nth-child(1) > span:nth-child(1)"
                            ).click()
        driver.find_element(By.CSS_SELECTOR, ".el-form-item:nth-child(1) .el-input__inner").send_keys("123456")
        driver.find_element(By.CSS_SELECTOR, ".el-form-item:nth-child(2) .el-input__inner").send_keys("123123三")
        driver.find_element(By.CSS_SELECTOR, ".el-form-item:nth-child(3) .el-input__inner").send_keys("123123三")

        driver.find_element(By.CSS_SELECTOR, ".dialog-footer > .el-button--primary > span").click()
        expect_tips = ["密码不能输入汉字","密码不能输入汉字"]
        time.sleep(3)
        got_tips = driver.find_elements(By.CLASS_NAME,"el-form-item__error")

        CHECK_POINT("提示信息是否一致", expect_tips[0] == got_tips[0].text
                    and  expect_tips[1] == got_tips[1].text
                    )
        # time.sleep(5)

